package com.accenture.automation.biz.api.interfaces;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.accenture.automation.biz.api.bean.ResponseBaseBean;
import com.accenture.automation.biz.api.producer.iface.ProducerService;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "/ITE")
public class TestInterface {
	@Autowired
	ProducerService producerService;
	@Value("${root_app}")
	private String rootApp;
	@Value("${TOPIC}")
	private String TOPIC;

	/**
	 * 报销单创建FI001
	 */
	@ApiOperation(value="报销单创建", notes="FI001")
	@ApiImplicitParam(name = "body", value = "参数", required = true, dataType = "String", paramType = "path")
	@RequestMapping(value = "/inid/FI001/create", method = RequestMethod.POST)
	@ResponseBody
	public Object reimbursementCreate(@RequestBody String body, HttpServletRequest request,
			HttpServletResponse response) {
		ResponseBaseBean<Object> rsBean = producerService.apiCreate(TOPIC, body, rootApp + "_" + "FI001");
		return rsBean;
	}

	/**
	 * 借款单据创建FI002
	 */
	@ApiOperation(value="借款单据创建", notes="FI002")
	@ApiImplicitParam(name = "body", value = "参数", required = true, dataType = "String", paramType = "path")
	@RequestMapping(value = "/inid/FI002/borrowingCreate", method = RequestMethod.POST)
	@ResponseBody
	public Object referenceStatusUpdate(@RequestBody String body, HttpServletRequest request,
			HttpServletResponse response) {
		ResponseBaseBean<Object> rsBean = producerService.apiCreate(TOPIC, body, rootApp + "_" + "FI002");
		return rsBean;
	}

	/**
	 * 对公报销申请创建FI003
	 */
	@ApiOperation(value="对公报销申请创建", notes="FI003")
	@ApiImplicitParam(name = "body", value = "参数", required = true, dataType = "String", paramType = "path")
	@RequestMapping(value = "/inid/FI003/npoCreate", method = RequestMethod.POST)
	@ResponseBody
	public Object voucherCreate(@RequestBody String body, HttpServletRequest request, HttpServletResponse response) {
		ResponseBaseBean<Object> rsBean = producerService.apiCreate(TOPIC, body, rootApp + "_" + "FI003");
		return rsBean;
	}

	/**
	 * 单据状态接口（作废、付款）FI004
	 */
	@ApiOperation(value="单据状态接口（作废、付款）", notes="FI004")
	@ApiImplicitParam(name = "body", value = "参数", required = true, dataType = "String", paramType = "path")
	@RequestMapping(value = "/inid/FI004/reimbursementStatus", method = RequestMethod.POST)
	@ResponseBody
	public Object createBorrowingSingle(@RequestBody String body, HttpServletRequest request,
			HttpServletResponse response) {
		ResponseBaseBean<Object> rsBean = producerService.apiCreate(TOPIC, body, rootApp + "_" + "FI004");
		return rsBean;
	}

	/**
	 * 凭证信息传输接口 FI005
	 */
	@ApiOperation(value="凭证信息传输接口", notes="FI005")
	@ApiImplicitParam(name = "body", value = "参数", required = true, dataType = "String", paramType = "path")
	@RequestMapping(value = "/inid/FI005/voucherCreate", method = RequestMethod.POST)
	@ResponseBody
	public Object createRepaymentSingle(@RequestBody String body, HttpServletRequest request,
			HttpServletResponse response) {
		ResponseBaseBean<Object> rsBean = producerService.apiCreate(TOPIC, body, rootApp + "_" + "FI005");
		return rsBean;
	}

}
